from dao.user_store import UserStore
from utils.date import get_date_now
import time


class UserService():

    def list(self):
        return UserStore().list()

    def update(self, user):
        print(user)
        UserStore().update_by_number(user)

    def login(self, username, password):
        return UserStore().findUserByPasswordAndUsername(username, password)

    def deleteUser(self, number):
        UserStore().delete_by_number(number)
        return True

    def addUser(self, user):
        # 获取当前时间
        user.create_time = get_date_now()
        UserStore().save(user)

